package BanyuanClub.Study.Day0308.多线程.习题一;

import BanyuanClub.Study.Day0308.多线程.习题一.CallableOne;
import BanyuanClub.Study.Day0308.多线程.习题一.CalllableTwo;

import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

/**
 * 两个线程同时分别计算数组偶数位置和技术位置的和，最后计算总和
 */
public class Text {
    private int[] arr = {1,2,3,4,5,6,7,8,9};

    public int[] getArr() {
        return arr;
    }

    public void setArr(int[] arr) {
        this.arr = arr;
    }

    public static void main(String[] args) throws ExecutionException, InterruptedException {
        FutureTask ft = new FutureTask(new CallableOne());
        FutureTask ft1 = new FutureTask(new CalllableTwo());
        Thread th1 = new Thread(ft);
        Thread th2 = new Thread(ft1);
        th1.start();
        th2.start();
        System.out.println(ft.get());
        System.out.println(ft1.get());

    }
}
